<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="../node_modules/@vue/reactivity/dist/reactivity.global.js"></script>
    <div id="app"></div>
    <script>
        const { reactive, readonly, shallowReadonly, shallowReactive, effect ,ref,toRef,toRefs} = VueReactivity;
        // shallowref用的比少

        // let r = ref(true);
        
       



        // ref 是基于普通类型，通过类似于 defindprortype 劫持get、set来依赖收集、触发更新，实现响应式，
        // toRef 不需要劫持，因为toRef是基于响应式数据进行提取，
        // 因为是对响应式数据进行操作，所以本身就会有get、set，通过访问其属性，触发get实现依赖收集，并将其放到ObjectRefImpl的value中
        // 使其变成通过value访问的响应式数据

        // let name = ref('zy')
        // {{name}}   {{age}} 
        //    console.log(toRefs(school))
        // let toref = toRef(school,'age')
        // console.log(toRef(school,'age'))

        // let name2 = toRef(name,'value')
        // console.log(name2,toref,name);
        debugger
        let school = reactive({name:'zf',age:12,arr:[1,2,3]})  
        
        effect(()=>{
            console.log(school.name);
            console.log(school.age);
            console.log(school.arr)
            console.log(school.arr[2])
        });
        

        setTimeout(() => {
            r.value = false;
            // name.value = 'zyy'
            
        }, 1000);
    </script>
</body>

</html> =